package DB;

import Entity.Pattern;

/** this class asks queries to get and insert pattern's details from and into the db  */
public class PatternQuery {
	
	public String [] CityList=new String[256];
	
	/**function which get selected product id's details from db */
	public static String getProductDB( String productID) 
	{

		/**Prepare queries*/		
		String str = "SELECT * FROM products WHERE ProductID = " + "\"" + productID + "\"";
		return str;
	}
	
	/**function which get acustomer's details from db where age is in range 
	 * 
	 * @param MinAge
	 * @param MaxAge
	 * @return
	 */
	public static String getCustomerDB(int MinAge,int MaxAge)
	{
		String str ="SELECT * FROM customers WHERE Age BETWEEN " + "\"" + MinAge + "\" AND " + "\"" + MaxAge + "\"";	
		return str;	
	}
	
	/**function which insert pattern's details into db */
	public static String InsertPatternQuery( Pattern Ptr)
	{
		return  "INSERT INTO pattern (PatternID , PatternName, ProductID,MinAge,MaxAge,Importance,Interest,Permission,City,Message) VALUES (\""
				+ Ptr.getPatternID()
				+ "\",\""
				+ Ptr.getPatternName()
				+ "\",\""
				+ Ptr.getProductID()
				+ "\","
				+ Ptr.getMinAge()
				+ ","
				+ Ptr.getMaxAge()
				+ ","
				+ Ptr.getImportance()
				+ ","
				+ Ptr.getInterest()
				+ ","
				+ Ptr.getPermission()
				+ ",\""
				+ Ptr.getCity()
				+"\",\""
				+ Ptr.getMessage()
				+ "\")";
	}

	/**function which get selected pattern id's patterns from db  */
	public static String getPatternQuery(String PatternID)
	{
		return "SELECT * FROM pattern WHERE PatternID = " + "\"" + PatternID + "\"";
	}
	
	/**function which get cities list from db*/	
	public static String getCities() 
	{
		return "SELECT * FROM cities" ;
	}
		
	/**functions which check if a field is empty */
	public  boolean isEmpty(String field) 
	{
		if (field.isEmpty())
			return true;
		return false;
	}
		
	public  boolean isEmpty(int field) 
	{
		if (field!=0)
			return true;
		return false;
	}
		
		
		
}